package cn.gdcp.listviewtest;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class AddActivity extends AppCompatActivity implements View.OnClickListener {
  EditText editName;
  EditText editAge;
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.add_layout);
        Button addStu=(Button)findViewById(R.id.add_stu);
        addStu.setOnClickListener(this);
        editName=findViewById(R.id.add_name);
        editAge=findViewById(R.id.add_age);
    }

    @Override
    public void onClick(View v) {
          String name=editName.getText().toString();
          int age=Integer.parseInt(editAge.getText().toString());
             int imgId=R.drawable.icon;
          Intent intent=new Intent();
          intent.putExtra("NAME",name);
          intent.putExtra("AGE",age);
          intent.putExtra("IMGID",imgId);
              setResult(200,intent);
              finish();
    }
}
